<template>
    <div>
      <a-form style="width:962px" :form="form">
        <a-row>
          <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="统一信用代码">
          <a-input :disabled="editType=='detail'" placeholder="请输入统一信用代码" v-decorator="['CompanyCode', validatorRules.companycode]" />
        </a-form-item>
      </a-col>
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="公司全称">
          <a-input :disabled="editType=='detail'" placeholder="请输入公司全称" v-decorator="['CompanyName', validatorRules.companyname]" />
        </a-form-item>
        </a-col>
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="公司简称">
          <a-input :disabled="editType=='detail'" placeholder="请输入公司简称" v-decorator="['CompanyAbbr', validatorRules.companyabbr]" />
        </a-form-item>
        </a-col>
      <a-col :span="24">
        <a-form-item class="labelColMax"
          label="一句话简介">
          <a-input :disabled="editType=='detail'" type="textarea" placeholder="请输入一句话简介" v-decorator="['CompanyBrief', {}]" />
        </a-form-item>
        </a-col>
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="法人代表">
          <a-select :disabled="editType=='detail'" placeholder="请选择" v-decorator="['LegalPerson', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.PersonalName" v-for="(item,index) in personData">{{item.PersonalName}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="成立日期">
          <a-date-picker :disabled="editType=='detail'" placeholder="请输入成立日期" v-decorator="['RegisteredDate', {}]" />
        </a-form-item>
        </a-col>
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="注册币种">
          <a-select :disabled="editType=='detail'" placeholder="请输入注册币种" v-decorator="['CurrencyTypeId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.BaseInfoId" v-for="(item,index) in currentTypeData">{{item.Value}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="注册资本">
          <a-input-number :disabled="editType=='detail'" style="width:90%;margin-right:5px" placeholder="请输入注册资本" v-decorator="['RegisteredAmt', {}]" />万
        </a-form-item>
        </a-col>
        
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="实缴资本">
          <a-input-number :disabled="editType=='detail'" style="width:90%;margin-right:5px" placeholder="请输入实缴资本" v-decorator="['PaidinAmt', {}]" />万
        </a-form-item>
        </a-col>
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="经营状态">
          <a-select :disabled="editType=='detail'" placeholder="请选择经营状态" v-decorator="['OperationStatusId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.BaseInfoId" v-for="(item,index) in opeStatusData">{{item.Value}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="注册城市">
          <a-select :disabled="editType=='detail'" placeholder="请输入所在城市" v-decorator="['CityId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.RegionId" v-for="(item,index) in cityArr">{{item.RegionName}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
      
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="注册区/县">
          <a-select :disabled="editType=='detail'" placeholder="请输入注册区/县" v-decorator="['RegisteredDistrictId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.RegionId" v-for="(item,index) in districtArr">{{item.RegionName}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
      <a-col :span="24">
        <a-form-item
          class="labelColMax"
          label="注册详细地址">
          <a-input :disabled="editType=='detail'" type="textarea" placeholder="请输入注册详细地址" v-decorator="['RegisteredAddress', {}]" />
        </a-form-item>
        </a-col>
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="办公城市">
          <a-select :disabled="editType=='detail'" placeholder="请输入所在城市" v-decorator="['OfficeCityId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.RegionId" v-for="(item,index) in cityArr">{{item.RegionName}}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="办公区/县">
          <a-select :disabled="editType=='detail'" placeholder="请输入办公区/县" v-decorator="['OfficeDistrictId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.RegionId" v-for="(item,index) in districtOfficeArr">{{item.RegionName}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
      <a-col :span="24">
        <a-form-item
          class="labelColMax"
          label="办公详细地址">
          <a-input :disabled="editType=='detail'" type="textarea" placeholder="请输入办公详细地址" v-decorator="['OfficeAddress', {}]" />
        </a-form-item>
        </a-col>
        
      <a-col :span="8">

        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="行业">
          <a-select :disabled="editType=='detail'" placeholder="请选择行业" v-decorator="['IndustryId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.BaseIndustryId" v-for="(item,index) in industryData">{{item.Industry}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
        <a-col :span="16">

        <a-form-item
          class="labelColMid"
          label="子行业">
          <a-select mode="multiple" :disabled="editType=='detail'" placeholder="请选择子行业" v-decorator="['SubIndustry', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.BaseIndustryId" v-for="(item,index) in secondIndustryData">{{item.Industry}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
      <a-col :span="24">
        <a-form-item
          class="labelColMax"
          label="行业标签">
          <a-select :disabled="editType=='detail'" mode="tags" placeholder="请输入行业标签" v-decorator="['IndustryTagId', {}]" >
            <a-select-option :value="item.IndustryTag" v-for="(item,index) in industryTagData">{{item.IndustryTag}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
        <a-col :span="8">
        
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="所属产业区域">
          <a-select :disabled="editType=='detail'" placeholder="请选择所属产业区域" v-decorator="['HighteckParkId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.BaseInfoId" v-for="(item,index) in parkArrFirst">{{item.Value}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
        
        <a-col :span="8">
        
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="所在园区">
          <a-select :disabled="editType=='detail'" placeholder="请选择所在产业园区" v-decorator="['SubParkId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.BaseHighteckParkId" v-for="(item,index) in secondParkArr">{{item.ParkName}}</a-select-option>
            <!-- <a-select-option :value="item.BaseHighteckParkId" v-for="(item,index) in parkArr">{{item.ParkName}}</a-select-option> -->
          </a-select>
        </a-form-item>
        </a-col>
        <!-- <a-col :span="8">
        
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="所属开发区">
          <a-input disabled  v-decorator="['ParkTypeName', {}]" />
            
        </a-form-item>
        </a-col> -->
        
        <a-col :span="24">
        <a-form-item
          class="labelColMax"
          label="公司介绍">
          <a-input :disabled="editType=='detail'" type="textarea" placeholder="请输入公司介绍" v-decorator="['CompanyDepiction', {}]" />
        </a-form-item>
        </a-col>
      <a-col :span="24">
        <a-form-item
          class="labelColMax"
          label="团队描述">
          <a-input :disabled="editType=='detail'" type="textarea" placeholder="请输入团队描述" v-decorator="['TeamRemark', {}]" />
        </a-form-item>
        </a-col>
        
      </a-row>
    
      </a-form>
    </div>

</template>

<script>
  import '@/assets/less/TableExpand.less'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import pick from 'lodash.pick'
  import moment from "moment"
  export default {
    name: "CompanyInteractiveList",
    mixins:[JeecgListMixin],
    components: {
        
    },
    props:{
      companyId:{
        type:String
      }
    },
    data () {
      return {
        // 表头
        parkArrFirst:[],
        districtOfficeArr:[],
        currentTypeData:[],
        secondParkArr:[],
        secondIndustryData:[],
        editType:'',
        industryData:[],
        industryTagData:[],
        opeStatusData:[{
          id:'5',
          name:'存续'
        },{
          id:'6',
          name:'在业'
        },{
          id:'7',
          name:'吊销'
        },{
          id:'9',
          name:'迁入'
        },{
          id:'10',
          name:'存续'
        },{
          id:'11',
          name:'迁出'
        },{
          id:'12',
          name:'停业'
        },{
          id:'13',
          name:'清算'
        }],
        editType:'detail',
        model:{},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 8 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 15 },
        },
        form: this.$form.createForm(this),
        validatorRules:{
        companyid:{rules: [{ required: true, message: '请输入公司ID!' }]},
        companycode:{rules: [{ required: true, message: '请输入统一信用代码!' }]},
        companyname:{rules: [{ required: true, message: '请输入公司全称!' }]},
        companyabbr:{rules: [{ required: true, message: '请输入公司简称!' }]},
        companybrief:{rules: [{ required: true, message: '请输入一句话简介!' }]},
        legalperson:{rules: [{ required: true, message: '请输入法人!' }]},
        registeredamt:{rules: [{ required: true, message: '请输入注册资本!' }]},
        paidinamt:{rules: [{ required: true, message: '请输入实缴资本!' }]},
        businessscope:{rules: [{ required: true, message: '请输入经营范围!' }]},
        registereddate:{rules: [{ required: true, message: '请输入成立日期!' }]},
        highteckparkid:{rules: [{ required: true, message: '请输入所属园区!' }]},
        cityid:{rules: [{ required: true, message: '请输入所在城市!' }]},
        registereddistrictid:{rules: [{ required: true, message: '请输入注册区/县!' }]},
        registeredaddress:{rules: [{ required: true, message: '请输入注册详细地址!' }]},
        officedistrictid:{rules: [{ required: true, message: '请输入办公区/县!' }]},
        officeaddress:{rules: [{ required: true, message: '请输入办公详细地址!' }]},
        isregoffsame:{rules: [{ required: true, message: '请输入办公与注册是否一致!' }]},
        operationstatusid:{rules: [{ required: true, message: '请输入经营状态!' }]},
        industryid:{rules: [{ required: true, message: '请输入所属行业!' }]},
        industrytagid:{rules: [{ required: true, message: '请输入行业标签!' }]},
        ishigtech:{rules: [{ required: true, message: '请输入是否高新企业!' }]},
        isbp:{rules: [{ required: true, message: '请输入是否有BP!' }]},
        teamtag:{rules: [{ required: true, message: '请输入团队标签!' }]},
        teamremark:{rules: [{ required: true, message: '请输入团队描述!' }]},
        staffsizeid:{rules: [{ required: true, message: '请输入人员规模!' }]},
        taxedsizeid:{rules: [{ required: true, message: '请输入纳税规模!' }]},
        valuationsizeid:{rules: [{ required: true, message: '请输入估值规模!' }]},
        refinanceroundid:{rules: [{ required: true, message: '请输入融资轮次!' }]},
        interactivecycleid:{rules: [{ required: true, message: '请输入互动周期!' }]},
        servicestatusid:{rules: [{ required: true, message: '请输入服务状态!' }]},
        linkerid:{rules: [{ required: true, message: '请输入Linker!' }]},
        updatebyid:{rules: [{ required: true, message: '请输入最近更新人!' }]},
        ts:{rules: [{ required: true, message: '请输入最近更新日期!' }]},
        datastatus:{rules: [{ required: true, message: '请输入状态!' }]},
        interactivetag:{rules: [{ required: true, message: '请输入互动标签!' }]},
        },
        parkArr:[],
        cityArr:[],
        districtArr:[],
        personData:[],
        url: {
          add: "/companyInfo/add",
          edit: "/companyInfo/update",
          baseList:"/baseInfo/queryRows",
        },
    }
  },
  created(){
    this.getPerson();
      this.getCity();
      this.getBaseData();
      this.getParkFirst();
      this.getIndustry();
      this.getIndustryTag();
  },
    mounted(){
      
      
    },
    methods: {
      open(){
        this.edit({CompanyId:this.companyId})
      },
      getIndustry(){
        this.$http.postAction('/baseIndustry/queryRows',{pageNo:1,pageSize:9999,selectFields:[],conditions:[{
              "field":"UpIndustry.Industry",
              "operator":"IS NULL",
              "value":""
            }]}).then((res)=>{
          if(res.status == 1){
            this.industryData = res.data.rows;
          }
        })
      },
      getIndustryTag(type){
        this.$nextTick(()=>{
          let data = this.form.getFieldsValue();
          if(type !== 'init'){
            this.form.setFieldsValue({
              IndustryTagId:[]
            })
          }
          this.$http.postAction('/baseIndustryTag/queryRows',{pageNo:1,pageSize:9999}).then((res)=>{
            if(res.status == 1){
              this.industryTagData = res.data.rows;
            }
          })
        })
        
      },
      getParkFirst(){
        this.$http.postAction(this.url.baseList,{pageNo:1,pageSize:100,selectFields:[],conditions:[{
              "field":"TypeCode",
              "operator":"=",
              "value":'ParkType'
            }]}).then(res=>{
            if(res.status == 1){
              this.parkArrFirst = res.data.rows;
            }
          })
      },
      getPark(){
        this.$http.postAction("/baseHighteckPark/queryRows",{pageIndex:1,pageSize:9999}).then(res=>{
            if(res.status == 1){
              this.parkArr = res.data.rows;
            }
          })

      },
      getBaseData(){
        this.$http.postAction(this.url.baseList,{pageNo:1,pageSize:100,selectFields:[],conditions:[{
              "field":"TypeCode",
              "operator":"=",
              "value":'OperationStatus'
            }]}).then((res)=>{
          if(res.status == 1){
            this.opeStatusData = res.data.rows;
          }
        })
        this.$http.postAction(this.url.baseList,{pageNo:1,pageSize:100,selectFields:[],conditions:[{
              "field":"TypeCode",
              "operator":"=",
              "value":'CurrencyType'
            }]}).then((res)=>{
          if(res.status == 1){
            this.currentTypeData = res.data.rows;
          }
        })
      },
      getCity(){
        this.$http.postAction("/baseRegion/queryRows",{pageIndex:1,pageSize:9999,selectFields:[],conditions:[{
              "field":"RegionType",
              "operator":"=",
              "value":2
            }]}).then(res=>{
            if(res.status == 1){
              this.cityArr = res.data.rows;
              let cityId = '';
            }
          })
      },
      getPerson(){
        this.$http.postAction('/personalInfo/queryRows',{pageNo:1,pageSize:9999}).then((res)=>{
          if(res.status == 1){
            this.personData = res.data.rows;
          }
        })
      },
      getDistrict(type){
        this.$nextTick(()=>{
          let data = this.form.getFieldsValue();
          let parentId = data.CityId;
          if(!parentId){
            return false;
          }
          if(type !== 'init'){
            this.form.setFieldsValue({
              RegisteredDistrictId:''
            })
          }
          this.districtArr = [];
          this.$http.postAction("/baseRegion/queryRows",{pageIndex:1,pageSize:9999,selectFields:[],conditions:[{
                "field":"Parent",
                "operator":"=",
                "value":parentId
              }]}).then(res=>{
              if(res.status == 1){
                this.districtArr = res.data.rows;
              }
            })
        })
      },
      getOfficeDistrict(type){
        this.$nextTick(()=>{
          let data = this.form.getFieldsValue();
          let parentId = data.OfficeCityId;
          if(!parentId){
            return false;
          }
          if(type !== 'init'){
            this.form.setFieldsValue({
              OfficeDistrictId:''
            })
          }
          this.districtOfficeArr = [];
          this.$http.postAction("/baseRegion/queryRows",{pageIndex:1,pageSize:9999,selectFields:[],conditions:[{
                "field":"Parent",
                "operator":"=",
                "value":parentId
              }]}).then(res=>{
              if(res.status == 1){
                this.districtOfficeArr = res.data.rows;
              }
            })
        })
      },
      changePark(){
        this.$nextTick(()=>{
          let data = this.form.getFieldsValue();
          let name = '';
          if(data.SubParkId){
            console.log('ffffg',this.parkArr)
            this.parkArr.forEach((e)=>{
              if(e.BaseHighteckParkId == data.SubParkId){
                name = e.ParkType_Value;
              }
            })
          }
          this.form.setFieldsValue({
            ParkTypeName:name,
            SubPark:null
          })
        })
      },
      getSecondIndustry(type){
        this.$nextTick(()=>{
          let data = this.form.getFieldsValue();
          if(type !== 'init'){
            this.form.setFieldsValue({
              SubIndustry:[]
            })
          }
          this.$http.postAction('/baseIndustry/queryRows',{pageNo:1,pageSize:9999,selectFields:[],conditions:[{
              "field":"UpIndustry",
              "operator":"=",
              "value":data.IndustryId?data.IndustryId:this.model.Industry
            }]}).then((res)=>{
            if(res.status == 1){
              this.secondIndustryData = res.data.rows;
            }
          })
        })
        
      },
      getSecondPark(type){
        this.$nextTick(()=>{
          let data = this.form.getFieldsValue();
          if(type !== 'init'){
            this.form.setFieldsValue({
              SubParkId:''
            })
          }
          this.$http.postAction('/baseHighteckPark/queryRows',{pageNo:1,pageSize:9999,selectFields:[],conditions:[{
              "field":"ParkType",
              "operator":"=",
              "value":data.HighteckParkId?data.HighteckParkId:this.model.HighteckPark
            }]}).then((res)=>{
            if(res.status == 1){
              this.secondParkArr = res.data.rows;
            }
          })
        })
      },
      edit (record) {
        this.form.resetFields();
        this.model = Object.assign({}, record);
        this.visible = true;
        this.companyId
        if(this.model.CompanyId){
          
            this.$http.postAction("/companyInfo/detail/map",this.model.CompanyId,{
            headers: {
              "Content-type": "application/text"
            }
           }).then(res=>{
              if(res.status == 1){
                res.data.CompanyId = this.model.CompanyId;
                this.model = res.data?res.data:{};
                // this.model.IndustryId = this.model.Industry;
                this.model.IndustryTagId = this.model.IndustryTag?this.model.IndustryTag.split(','):[];
                // this.model.OperationStatusId = this.model.OperationStatus;
                // this.model.CityId = this.model.City;
                // this.model.OfficeDistrictId = this.model.OfficeDistrict;
                // this.model.RegisteredDistrictId = this.model.RegisteredDistrict;
                this.model.HighteckParkId = this.model.HighteckPark?this.model.HighteckPark.BaseInfoId:'';
                this.model.SubParkId = this.model.SubPark?this.model.SubPark.Id:'';
                this.model.SubIndustryId = this.model.SubIndustry?this.model.SubIndustry.split(','):[];
                this.model.SubIndustry = [];
                if(this.model.SubIndustries){
                  this.model.SubIndustries.forEach((e)=>{
                    this.model.SubIndustry.push(e.SubIndustryId)
                  })
                }
                // this.model.CurrencyTypeId = this.model.CurrencyType;
              }
              this.$nextTick(() => {
                this.form.setFieldsValue(pick(this.model,'CompanyCode','CompanyName','CompanyAbbr','CompanyBrief','LegalPerson','RegisteredAmt','PaidinAmt','HighteckParkId','CityId','OfficeCityId','RegisteredDistrictId','RegisteredAddress','OfficeDistrictId','OfficeAddress','OperationStatusId','IndustryId','IndustryTagId','TeamRemark','CompanyDepiction','SubIndustry','SubParkId','CurrencyTypeId'))
                this.getDistrict('init');
                this.getOfficeDistrict('init');
                //时间格式化
                this.form.setFieldsValue({RegisteredDate:this.model.RegisteredDate?moment(this.model.RegisteredDate,'YYYY-MM-DD HH:mm:ss'):null})
                })
                this.changePark();
                this.getSecondIndustry('init');
                this.getSecondPark('init'); 
              });
              
              
        }                                        
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
<style>
  .labelColMax .ant-form-item-label{
    width: 107px;
    float: left;
  }
  .labelColMax .ant-form-item-control-wrapper{
    width: calc(100% - 120px);
    display: inline-block;
  }
  .labelColMid .ant-form-item-label{
    width: 107px;
    float: left;
  }
  .labelColMid .ant-form-item-control-wrapper{
    width: calc(100% - 120px);
    display: inline-block;
  }
</style>